<template>
	<div>
		<el-select v-model="SystemLevelId" :placeholder="placeholderData" filterable @click="getSystemLevelData" :style="styleData">
		  <el-option v-for="i in systemLevelOptions" :key="i.systemLevelTypeId" :label="i.typeName" :value="i.systemLevelTypeId"></el-option>
		</el-select>
	</div>
</template>
<script>/** 选择全部系统分类 **/
	import systemLevelTypeAPI from '@/api/system/systemLevelType';
	export default {
		name: "selectSystem",
		props: ["parentLoadingFunction",//等待显示回调函数
				"parentGetData",//加载数据回调函数
				"styleData",//樣式内容
				"placeholderData",
			],
		data() {
			return {
				SystemLevelId: "",
				systemLevelOptions: [],
				hasSelSysBranchOffice: false,
			}
		},
		watch: {
			SystemLevelId(val){
				let itemno=null, vs=null;
				for(vs in this.systemLevelOptions){
					if(this.systemLevelOptions[vs].systemLevelTypeId == val){
						itemno = this.systemLevelOptions[vs];
					}
				}
				this.parentGetData(itemno);
			},
		},
		computed: {
		},
		mounted(){
		},
		methods: {
			async getSystemLevelData(){
				if(this.systemLevelOptions.length < 1){
					this.parentLoadingFunction(true);
					let reqData = {"current": 1,"size": 30};
					var res = await systemLevelTypeAPI.systemLevelType.list.get(reqData);
					this.parentLoadingFunction(false);
					if(res.code === 2000){
						this.systemLevelOptions=res.data.records;
					}else{
						this.$alert(res.message, "提示", {type: 'error'});
					}
				}
			},
		}
	}
</script>
